package mop.exception;

/**
 * Exception class to be thrown when an illegal termination is tried to be executed
 * 
 * @invar none this is a exception
 * 
 * @author	 MOP Team 7
 */
public class IllegalTerminationException extends Throwable 
{

	/**
	 * Initializes an IllegalTerminationException with the passed name
	 * 
	 * @param name
	 *  the identifier of the object that could not be terminated
	 * 
	 * @param type
	 *  the type of the object that could not be terminated
	 *  
	 * @effect sets the name
	 *  |setName(name)
	 * @effect sets the type
	 *  |setType(type)
	 *  
	 * @post Exception is created
	 */
	public IllegalTerminationException(String name, String type)
	{
		this.setName(name);
		this.setType(type);
	}
	
	/**
	 * return a error message that can be used by the gui
	 * 
	 * @return an error message describing the name and type of the object that couldn't be terminated
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("Termination of "+ this.type +": "+ this.name +" failed.");
		return sb.toString();
		
	}
	
	 /**
	  * set the name
	  * 
	  * @param name
	  *  the name that's causing trouble
	  *  
	  * @post the name is set to the passed one
	  * 
	  */
	 private void setName(String name) 
	 {

		 this.name = name;
	 }
	
	/**
	 * the identifier / name thats causing the problem
	 */
	private String name;
	
	 /**
	  * set the object type
	  * 
	  * @param type
	  *  the type that's causing trouble
	  *  
	  * @post the type is set to the passed one
	  * 
	  */
	 private void setType(String type) 
	 {

		 this.type = type;
	 }
	
	/**
	 * the object type thats causing the problem
	 */
	private String type;
	
	/**
	 * weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
}


